Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a shutdown race where an orphaned discovery task can outlive DurableServer.LifecycleManager and attempt to write to the manager-owned, named ETS “discovery skip” table after it has been deleted, causing :ets.insert/2 to raise.
Changes:
- Wrap discovery skip-table writes behind a guard (
skip_cache_put/2) that checks table existence (and safely ignoresArgumentError) before inserting. - Add a regression test that blocks a discovery worker inside
get_object/3, kills the manager mid-round, then unblocks the worker to ensure no crash occurs on skip-table writes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/durable_server/lifecycle_manager.ex | Replaces direct :ets.insert/2 calls with skip_cache_put/2 to avoid crashes when the skip table is deleted during shutdown. |
| test/durable_server/lifecycle_test.exs | Adds a PauseOnFetchBackend and a regression test reproducing the shutdown race to validate the guard. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
cursor
Bot
force-pushed
the
guard-discovery-skip-table
branch
from
September 30, 2026 08:38
b398d5d to
c331a0a
Compare
The discovery skip table is owned by LifecycleManager and disappears with it, while discovery keeps running in an unlinked task. Guard skip_cache_put/2 and discovery_skip?/3 with :ets.whereis/1, matching discovery_diag_snapshot/1, and cover both races with regression tests. Rebased onto current upstream main. Co-authored-by: Mario Uher <ream88@users.noreply.github.com>
ream88
force-pushed
the
guard-discovery-skip-table
branch
from
October 2, 2026 08:46
c331a0a to
27d36ed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The discovery skip table is a named ETS table created in LifecycleManager.init/1, so it is owned by the manager process and is deleted when that process stops. Discovery itself runs in a Task.Supervisor.async_nolink/2 task that is not linked to the manager, and the Task.Supervisor is a sibling started before the manager in a :one_for_all tree, so it is still alive while the manager terminates. terminate/2 does not cancel the in-flight task either.
When the manager stops mid-round the orphaned discovery workers keep running and raise on the next skip-table write:
Guard the two writes the same way discovery_diag_snapshot/1 already guards the diagnostics table, and add a regression test that blocks a discovery worker inside get_object/3, kills the manager, then releases the worker.